package org.libarae.server.exceptions;

/**
 * @author Tyler Holzer
 * 
 * ConfigParseException.java -- A part of Libarae
 * An exception which tells what went wrong while reading the XML
 */
@SuppressWarnings("serial")
public class ConfigParseException extends Exception {
	
	//types of errors
	/**
	 * type if an invalid argument was found, causing an XMLError
	 */
	public static final int INVALID_ARGUMENT_IN_XML=0;
	/**
	 * type if the variable databaseType was not set
	 */
	public static final int DATABASE_TYPE_NOT_SET=1;
	/**
	 * type if the variable DatabaseExists was not set
	 */
	public static final int DATABASE_EXISTANCE_NOT_SPECIFIED=2;
	/**
	 * type if the variable imageFolderExists was not set
	 */
	public static final int IMAGE_FOLDER_EXISTANCE_NOT_SPECIFIED=3;
	
	/**
	 * type if the variable ISBNdbAccessKey was not set
	 */
	public static final int ISBNDB_ACCESS_KEY_NOT_SET =4;
	
	/**
	 * the reason why the parsing of the file failed
	 */
	private int type;
	
	/**
	 * Constructor
	 * 
	 * @param type - the type of the issue
	 */
	public ConfigParseException(int type) {
		super("An error occured while reading the XML config file");
		this.type=type;
	}
	
	/**
	 * Constructor which allows a custom message to be set
	 * 
	 * @param type -- the type of the issue
	 * @param message -- the custom message
	 */
	public ConfigParseException(int type, String message) {
		super(message);
		this.type=type;
	}
	
	/**
	 * returns the type of the exception
	 * 
	 * @return int
	 */
	public int getType() {
		return type;
	}
}
